<?php

require_once 'common/conn.php';
$result = array();
if (isset($_GET['usercode'])) {
    $usercode = $_GET['usercode'];
} else if (isset($_POST['usercode'])) {
    $usercode = $_POST['usercode'];
}

if (isset($_GET['amount'])) {
    $amount = $_GET['amount'];
} else if (isset($_POST['amount'])) {
    $amount = $_POST['amount'];
}

if (isset($_GET['content'])) {
    $content = $_GET['content'];
} else if (isset($_POST['content'])) {
    $content = $_POST['content'];
}

$db = new DBC();
$result['errorNo'] = 0;
if (isset($amount) && isset($usercode) && isset($content)) {
    $sql = "INSERT INTO t_hibay_buy_record(usercode,amount,content,createTime) VALUES('"
            . $usercode . "','" . $amount . "'," . $content . ",now())";
    if ($db->execute($sql)) {
        $result['errorNo'] = "0";
        $result['errorMsg'] = "";
    } else {
        $result['errorNo'] = "1";
        $result['errorMsg'] = "购买物品错误";
    }
} else {
    $result['errorNo'] = "2";
    $result['errorMsg'] = "提交参数不完整";
}
echo json_encode($result);
?>
